package com.wonder.common;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.generator.AutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;


import java.util.Collections;

public class CodeGenerator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://10.10.110.17:3306/deyuan?serverTimezone=Asia/Shanghai",
                "root", "Asdwsx@1234")
                .globalConfig(builder -> {
                    builder.author("sunyonfa") // 设置作者
                            .outputDir(System.getProperty("user.dir") + "/src/main/java") // 指定输出目录
                            .disableOpenDir(); // 生成后不打开文件夹
                })
                .packageConfig(builder -> {
                    builder.parent("com.wonder.peizi") // 设置包名
                            .entity("entity")
                            .service("service")
                            .serviceImpl("service.impl")
                            .mapper("Dao")
                            .xml("dao.xml")
                            .pathInfo(Collections.singletonMap(OutputFile.mapper,
                                    System.getProperty("user.dir") + "/src/main/resources/mapper"));
                })
                .strategyConfig(builder -> {
                    builder.addInclude("t_sync_order") // 设置需要生成的表名
                            .addTablePrefix("t_") // 过滤表前缀
                            .entityBuilder().enableLombok(); // 实体类使用 Lombok
                })
                .execute();
    }
}
